package com.example.bootasync.gen;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

/**
 * @author : JinMing Zhou
 * @description: mbp代码生成器
 * @date : 2022/12/16 9:42
 */
public class CodeGet {

    // 表名
    private static final String[] tables = {"mq_order","mq_prod"};

    public static void main(String[] args) {
        String url = "jdbc:mysql://127.0.0.1:3306/test_mq?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
        FastAutoGenerator.create(url, "root", "root")
                .globalConfig(builder -> {
                    builder.author("JiMing Zhou") // 设置作者
                            .outputDir("F:\\I\\RabbitMQ\\rabbit-mq\\boot-async\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.example.bootasync") // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.xml,
                                    "F:\\I\\RabbitMQ\\rabbit-mq\\boot-async\\src\\main\\resources")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().enableLombok();
                    builder.controllerBuilder().enableHyphenStyle()  // 开启驼峰转连字符
                            .enableRestStyle();  // 开启生成@RestController 控制器
                    builder.addInclude(tables) // 设置需要生成的表名
                            .addTablePrefix("mq_"); // 设置过滤表前缀
                })
                .execute();
    }

}

